package com.queet.transaction.core.action;

import java.util.Map;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.web.context.ServletConfigAware;

import com.opensymphony.xwork2.ActionSupport;

/**
 * base action,all action must extends this action
 * @author Howard
 *
 */
public abstract class  BaseAction extends ActionSupport implements ServletRequestAware,
		SessionAware, ServletConfigAware {

	private static final long serialVersionUID = -1818836831976771437L;
	private HttpServletRequest request;
	private Map<String, String> session;
	private ServletContext application;
	
	String viewpath; //该属性会在struts.xml中用到，作为跳转的路径

    public String view(String vpath){
        viewpath = vpath;
        return "view";
    }

    public String redirect(String vpath){
        viewpath = vpath;
        return "redirect";
    }


    public String getViewpath() {
        return viewpath;
    }

	public void setServletRequest(HttpServletRequest request) {
		this.request =request; 
	}

	
	@SuppressWarnings("unchecked")
	public void setSession(Map session) {
		this.session = session;
	}
	
	/**
	 * 设置上下文
	 */
	public void setServletConfig(ServletConfig servletConfig) {
		this.application=servletConfig.getServletContext();
	}
	
	
	
	public HttpServletRequest getRequest() {
		return request;
	}

	public Map<String, String> getSession() {
		return session;
	}

	public ServletContext getApplication() {
		return application;
	}
	
	
}
